using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.IO;


namespace SymAutomate
{
    /// <summary>
    /// Summary description for Logger
    /// </summary>
    public class Logger
    {
        private static object synchronizeVariable = "locking";
        private string __FileName;

        public enum LogType
        {
            GeneralInfo
        }

        public Logger(LogType LogTypeIn)
        {
            this.InitializeConstructor(LogTypeIn);
        }

        private void InitializeConstructor(LogType LogTypeIn)
        {
            if (LogTypeIn == LogType.GeneralInfo)
                __FileName = System.Configuration.ConfigurationManager.AppSettings["LOG_Info"].ToString();
        }

        public void WriteLine(string _LineToWrite)
        {
            if (string.IsNullOrEmpty(__FileName))
                throw new Exception("File name is null or blank. Must set file name before calling WriteLine");

            lock (synchronizeVariable)
            {
                StreamWriter _StreamWriter = new StreamWriter(__FileName, true);
                _StreamWriter.Write(DateTime.Now);
                _StreamWriter.Write("    ");
                _StreamWriter.Write(_LineToWrite);
                _StreamWriter.WriteLine();
                _StreamWriter.Close();
            }
        }
    }
}
